home *** CD-ROM | disk | FTP | other *** search
/ The Essential Home & Business Collection / The Essential Home & Business Collection.iso / 27 / 3 / 5 / HP22D5.ZIP / EXTERN / FIXENV.ASM < prev    next >
Assembly Source File  |  1991-04-16  |  2KB  |  93 lines

  1. ; ---------------------------------------------------------------------------
  2. ; FIXENV.ASM
  3. ;
  4. ; This program sets HyperPAD's environment to the original environment used
  5. ; by COMMAND.COM. Also, the environment that HyperPAD passes to other programs
  6. ; when they are run is the actual environment of COMMAND.COM.
  7. ;
  8. ; It performs the following steps:
  9. ;
  10. ;    1. get the address of the first memory block
  11. ;    2. it assumes the second memory block is COMMAND.COM. It finds the
  12. ;       next memory block owned by this memory block
  13. ;    3. this memory block is inserted into the HyperPAD shared data
  14. ;       area as the new environment
  15. ;    4. the size of the memory block is calculated and inserted into the
  16. ;       appropriate field in the shared data area
  17. ;
  18. ; ---------------------------------------------------------------------------
  19. DOSSEG
  20. .MODEL        LARGE
  21.  
  22. include        extern.inc
  23.  
  24. .DATA
  25.  
  26. FixEnvName      db        'STARTUP',0
  27.  
  28. Pool        PoolStruct    <FixEnvName,FixEnv,,HANDLER>
  29.         PoolStruct    <>    ;END
  30.  
  31. .CODE
  32.  
  33. WhenLoaded:
  34. WhenUnLoaded:    retf
  35.  
  36. EXTRN        GetSharedArea:FAR
  37. FixEnv        proc far
  38.  
  39.         push    es
  40.         push    si
  41.         push    di
  42.  
  43.         mov    ah,52h        ;undocumented DOS interrupt
  44.         int    21h
  45.  
  46.         dec    bx        ;ES:[BX-2] = first memory block
  47.         dec    bx
  48.  
  49.         mov    si,3        ;memory block offset of size
  50.         mov    di,1        ;memory block offset of owner
  51.  
  52.         mov    ax,es:[bx]    ;AX = seg of first memory block
  53.         mov    es,ax
  54.         mov    bx,es:[si]    ;BX = size of first memory block
  55.         inc    bx
  56.         add    ax,bx        ;AX = seg of second memory block
  57.         mov    es,ax
  58.         mov    dx,es:[di]    ;DX = owner of second mem block (COMMAND.COM)
  59. loop1:
  60.         mov    bx,es:[si]    ;BX = size of block
  61.         mov    cx,bx        ;CX = block size (save for later)
  62.         inc    bx
  63.         add    ax,bx        ;AX = segment of next block
  64.         mov    es,ax
  65.         cmp    dx,es:[di]    ;check owner
  66.         jnz    loop1        ;not this block ... find next one
  67.  
  68.         inc    ax
  69.         mov    si,ax        ;SI = segment first COMMAND.COM environment
  70.         mov    di,cx        ;DI = size of block
  71.  
  72.         call    GetSharedArea    ;DX:AX far pointer to shared data area
  73.         mov    es,dx
  74.         mov    bx,ax        ;ES:BX = pointer to shared data area
  75.  
  76.         mov    es:[bx+618],si    ;EnvSeg = segment of COMMAND.COM's environment
  77.         mov    cl,4
  78.         shl    di,cl        ;convert paragraphs to bytes
  79.         mov    es:[bx+624],di    ;EnvSegSz = size fo environment block
  80.  
  81.         mov    ax,PASS        ;pass the startup message on
  82.  
  83.         pop    di
  84.         pop    si
  85.         pop    es
  86.  
  87.         ret
  88. FixEnv        endp
  89.  
  90. END
  91.  
  92.  
  93.